<?php

// Define path to application directory
// 中文
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));


/** Zend_Application */
require_once 'Zend/Application.php'; 

/** Public functions */
function p($r)
{
    echo "<pre>";
    print_r($r);
    echo "</pre>";
}

function getIni()
{
    if(file_exists(APPLICATION_PATH . '/configs/application.ini.cache')) {
        return unserialize(file_get_contents(APPLICATION_PATH . '/configs/application.ini.cache'));
    }
    return APPLICATION_PATH . '/configs/application.ini';
}


//For Apache 1.3
/*
if (get_magic_quotes_gpc()) {
    function stripslashes_deep($value)
    {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
*/

// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, getIni());

$application->bootstrap()->run();
